Skip to content

Provision RBAC for Kubeconfigs inside kcp#91

Merged
kcp-ci-bot merged 24 commits intokcp-dev:mainfrom
xrstf:kubeconfig-authz
Jan 22, 2026
Merged

Provision RBAC for Kubeconfigs inside kcp#91
kcp-ci-bot merged 24 commits intokcp-dev:mainfrom
xrstf:kubeconfig-authz

Conversation

@xrstf
Copy link
Contributor

@xrstf xrstf commented Sep 4, 2025

Summary

This PR implements a new feature for the operator: It can now provision RBAC inside kcp and thereby grant people permissions and take them away, too.

This is now the first PR to make use of the internal-proxy (#87): since admins can configure any random workspace path or cluster name, the operator needs to be able to provision on any shard and more importantly, figure out which shard. To solve this, we use our internal proxy ("internal" still means a standalone Deployment, of course).

Each Kubeconfig object can now hold a workspace and a desired list of permissions inside that workspace. The operator will try to reconcile these RBAC resources accordingly, and also take care of cleaning up when a Kubeconfig is removed or changed (it's possible for users to change the workspace that RBAC should be placed in, and the operator will first cleanup the old cluster and then provision the new one).

To keep track of where RBAC has been deployed, a new field in the Kubeconfig status has been introduced. We discussed this and decided that this is a safe place to do so, as anyone with permissions to manage Kubeconfigs is technically an admin and so endusers cannot/should not fiddle with Kubeconfigs. If that were possible, the operator currently has no way of defending against malicious changes.

Each kubeconfig manages its own RBAC and all resources inside kcp are named based on the UID of the Kubeconfig object. This ensures uniqueness all around and avoids having to merge desired RBACs into one ClusterRole(Binding) and unfiddle them when RBAC for one Kubeconfig is removed.

Notably, since the kcp-operator now has to talk with shards and the front-proxy, this PR modifies the local e2e setup to work like the CI e2e test: build an operator image and deploy it into kind, rather than running the operator on the host machine. This is a bit sad for quick debugging tests, but saves us from somehow having to either dynamically expose the pods through kind to the host, or rewriting URLs in the operator somehow.

What Type of PR Is This?

/kind feature

Related Issue(s)

Fixes #49

Release Notes

Add authorization options to Kubeconfigs: the operator can now grant permissions to access a workspace to make newly created Kubeconfigs immediately useful.

@kcp-ci-bot kcp-ci-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the DCO. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 4, 2025
@kcp-ci-bot kcp-ci-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2025
@kcp-ci-bot kcp-ci-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 20, 2025
@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 29, 2025
@xrstf
Copy link
Contributor Author

xrstf commented Oct 29, 2025

/kind feature

@kcp-ci-bot kcp-ci-bot added kind/feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 29, 2025
@xrstf
Copy link
Contributor Author

xrstf commented Nov 3, 2025

/retest

Comment on lines +62 to +65
clusterRoles:
items:
type: string
type: array
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does clusterRoles only reference objects that already exist in the cluster? I am wondering if it could be made possible to also configure RBAC inside the cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this is only binding to pre-existing ClusterRoles, yes.

@xrstf
Copy link
Contributor Author

xrstf commented Nov 7, 2025

/retest

4 similar comments
@xrstf
Copy link
Contributor Author

xrstf commented Nov 7, 2025

/retest

@xrstf
Copy link
Contributor Author

xrstf commented Nov 7, 2025

/retest

@xrstf
Copy link
Contributor Author

xrstf commented Nov 7, 2025

/retest

@xrstf
Copy link
Contributor Author

xrstf commented Nov 17, 2025

/retest

@xrstf xrstf changed the title WIP - Kubeconfig RBAC Provision RBAC for Kubeconfigs inside kcp Nov 17, 2025
@kcp-ci-bot kcp-ci-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 17, 2025
@xrstf
Copy link
Contributor Author

xrstf commented Nov 17, 2025

/merge-method squash

@xrstf xrstf added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 17, 2025
@xrstf xrstf force-pushed the kubeconfig-authz branch from 9919352 to ab42d4a Compare January 5, 2026 15:13
@kcp-ci-bot kcp-ci-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 5, 2026
@xrstf
Copy link
Contributor Author

xrstf commented Jan 5, 2026

@mjudeikis PTAL :)

Copy link
Contributor

@mjudeikis mjudeikis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nits. I still dont like the fact its public functions, pointers and we hope users will do the right thing without single code comments on the functions "what is the right thing" :D

Comment on lines 70 to 72
// only one of these three should be provided, the others nil
rootShard *operatorv1alpha1.RootShard,
shard *operatorv1alpha1.Shard,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its a lie. They are called from public function where they are pointers and there is no nil checking. Either add checking or make them non-pointers

Copy link
Contributor Author

@xrstf xrstf Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kube objects are basically in 99.9999% of cases kept on the heap and dereferencing them will just lead to annoying-to-use variables.

But I've added extra nil checks, even though they are validated in getRootShard(). :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored the code now to get rid of this triple parameter.

@xrstf xrstf requested a review from mjudeikis January 20, 2026 16:17
Copy link
Contributor

@mjudeikis mjudeikis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 22, 2026
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

DetailsGit tree hash: e97c507f6cae281e2fb24528ef72895f10908486

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjudeikis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 22, 2026
@kcp-ci-bot kcp-ci-bot merged commit 380180b into kcp-dev:main Jan 22, 2026
11 checks passed
@xrstf xrstf deleted the kubeconfig-authz branch February 2, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: allow RBAC bootstrapping for user identities in Kubeconfigs

5 participants